// export default singletonPrint

const SingletonPrint = {
  name: 'print class',
  printList: [] as string[],
  // 是否初始化js
  isInitJs: false,
  // 默认选中的打印机
  defaultPrinter: '',
}

// 页面加载时从 localStorage 中恢复 singletonPrint 对象
const savedData = localStorage.getItem('singletonPrint')
if (savedData) {
  try {
    const parsedData = JSON.parse(savedData)
    Object.assign(SingletonPrint, parsedData)
  } catch (error) {
    console.error('恢复singletonPrint数据失败:', error)
  }
}

// 页面关闭后需要将 singletonPrint 对象放到 localStorage 中
window.addEventListener('beforeunload', () => {
  localStorage.setItem('singletonPrint', JSON.stringify(SingletonPrint))
})

// 初始化类
// SingletonPrint.init()

export default SingletonPrint
